package org.jiusan.project.controller;

import java.util.Date;
import java.util.List;

import org.jiusan.project.entity.InterfaceInfo;
import org.jiusan.project.service.InterfaceServiceImpl;

public class InterfaceController {
	private InterfaceServiceImpl interfaceService;
	
	public void addInterface(long userId,InterfaceInfo info){
		info.setCreateId(userId);
		info.setCreateTime(new Date());
		info.setUsed(true);
		info.setDelete(false);
		interfaceService.addInterfaceInfo(info);
	}
	
	public String toupdate(int type){
		String page = null;
		if(type == 1){
			page = "add";
		}
		if(type == 2){
			page = "edit";
		}
		return page;
	}
	
	public void editInterfaceInfo(long userId,InterfaceInfo info) {
		info.setCreateId(userId);
		info.setCreateTime(new Date());
		info.setUsed(true);
		info.setDelete(false);
		interfaceService.editInterfaceInfo(info);
	}
	
	public void deleteInterfaceInfo(long userId,long infoId){
		interfaceService.deleteInterfaceInfo(infoId, userId);
	}
	
	public InterfaceInfo getInterfaceInfoById(long infoId){
		return interfaceService.getInterfaceInfoById(infoId);
	}
	
	public List<InterfaceInfo> getInterfaceInfoList(){
		return interfaceService.getList();
	}
	
	public List<InterfaceInfo> getInterfaceInfoRelationList(long relationId) {
		return interfaceService.getInterfaceInfoRelationList(relationId);
		
	}
}
